<template>
  <div class="antifraud-index">
    <!-- 页面头部 -->
    <div class="page-header">
      <h1>反诈知识库</h1>
      <p>学习反诈知识，提升安全防范能力</p>
    </div>

    <!-- 风险概览 -->
    <div class="risk-overview">
      <div class="overview-cards">
        <div class="overview-card risk-high">
          <div class="card-icon">⚠️</div>
          <div class="card-content">
            <div class="card-title">高风险警报</div>
            <div class="card-value">{{ riskStats.high }}</div>
            <div class="card-trend">
              <span class="trend-icon">📈</span>
              <span class="trend-text">较昨日 +15%</span>
            </div>
          </div>
        </div>
        
        <div class="overview-card risk-medium">
          <div class="card-icon">🔸</div>
          <div class="card-content">
            <div class="card-title">中风险提醒</div>
            <div class="card-value">{{ riskStats.medium }}</div>
            <div class="card-trend">
              <span class="trend-icon">📊</span>
              <span class="trend-text">较昨日 +8%</span>
            </div>
          </div>
        </div>
        
        <div class="overview-card risk-low">
          <div class="card-icon">✅</div>
          <div class="card-content">
            <div class="card-title">安全检测</div>
            <div class="card-value">{{ riskStats.safe }}</div>
            <div class="card-trend">
              <span class="trend-icon">📉</span>
              <span class="trend-text">较昨日 -5%</span>
            </div>
          </div>
        </div>
        
        <div class="overview-card total-checks">
          <div class="card-icon">🔍</div>
          <div class="card-content">
            <div class="card-title">今日检测</div>
            <div class="card-value">{{ riskStats.total }}</div>
            <div class="card-trend">
              <span class="trend-icon">⚡</span>
              <span class="trend-text">实时更新</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 快速功能导航 -->
    <div class="quick-nav">
      <h3>快速功能</h3>
      <div class="nav-grid">
        <div class="nav-item" @click="navigateTo('risk-assessment')">
          <div class="nav-icon">🎯</div>
          <div class="nav-content">
            <h4>风险评估</h4>
            <p>全面评估诈骗风险等级</p>
          </div>
          <div class="nav-arrow">→</div>
        </div>
        
        <div class="nav-item" @click="navigateTo('fraud-identification')">
          <div class="nav-icon">🔍</div>
          <div class="nav-content">
            <h4>诈骗识别</h4>
            <p>智能识别诈骗类型</p>
          </div>
          <div class="nav-arrow">→</div>
        </div>
        
        <div class="nav-item" @click="navigateTo('knowledge-base')">
          <div class="nav-icon">📚</div>
          <div class="nav-content">
            <h4>反诈知识库</h4>
            <p>防诈骗知识学习</p>
          </div>
          <div class="nav-arrow">→</div>
        </div>
        
        <div class="nav-item" @click="navigateTo('case-analysis')">
          <div class="nav-icon">📊</div>
          <div class="nav-content">
            <h4>案例分析</h4>
            <p>典型诈骗案例解析</p>
          </div>
          <div class="nav-arrow">→</div>
        </div>
      </div>
    </div>

    <!-- 最新警报 -->
    <div class="latest-alerts">
      <div class="alerts-header">
        <h3>最新警报</h3>
        <div class="alert-filters">
          <button v-for="filter in alertFilters" :key="filter.id"
                  @click="activeFilter = filter.id"
                  :class="{ active: activeFilter === filter.id }"
                  class="filter-btn">
            {{ filter.name }}
          </button>
        </div>
      </div>
      
      <div class="alerts-list">
        <div v-for="alert in filteredAlerts" :key="alert.id" class="alert-item" :class="alert.level">
          <div class="alert-icon">
            <i v-if="alert.level === 'high'">🚨</i>
            <i v-else-if="alert.level === 'medium'">⚠️</i>
            <i v-else>ℹ️</i>
          </div>
          <div class="alert-content">
            <div class="alert-title">{{ alert.title }}</div>
            <div class="alert-description">{{ alert.description }}</div>
            <div class="alert-meta">
              <span class="alert-time">{{ alert.time }}</span>
              <span class="alert-type">{{ alert.type }}</span>
            </div>
          </div>
          <div class="alert-actions">
            <button @click="viewAlert(alert)" class="view-btn">查看</button>
            <button @click="handleAlert(alert)" class="handle-btn">处理</button>
          </div>
        </div>
      </div>
    </div>

    <!-- 诈骗类型分析 -->
    <div class="fraud-analysis">
      <h3>诈骗类型分析</h3>
      <div class="analysis-content">
        <div class="fraud-chart">
          <div class="chart-container">
            <canvas ref="fraudChart" width="400" height="300"></canvas>
          </div>
        </div>
        
        <div class="fraud-stats">
          <div class="stat-item" v-for="stat in fraudStats" :key="stat.type">
            <div class="stat-label">{{ stat.type }}</div>
            <div class="stat-bar">
              <div class="bar-fill" :style="{ width: stat.percentage + '%', backgroundColor: stat.color }"></div>
            </div>
            <div class="stat-value">{{ stat.count }} ({{ stat.percentage }}%)</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 实时监控 -->
    <div class="real-time-monitor">
      <h3>实时监控</h3>
      <div class="monitor-grid">
        <div class="monitor-item">
          <div class="monitor-header">
            <h4>检测活动</h4>
            <div class="status-indicator active">🟢 运行中</div>
          </div>
          <div class="monitor-content">
            <div class="activity-list">
              <div v-for="activity in recentActivities" :key="activity.id" class="activity-item">
                <div class="activity-time">{{ activity.time }}</div>
                <div class="activity-desc">{{ activity.description }}</div>
                <div class="activity-result" :class="activity.result">{{ activity.result }}</div>
              </div>
            </div>
          </div>
        </div>
        
        <div class="monitor-item">
          <div class="monitor-header">
            <h4>风险趋势</h4>
            <div class="trend-indicator">📈 上升</div>
          </div>
          <div class="monitor-content">
            <div class="trend-chart">
              <canvas ref="trendChart" width="300" height="200"></canvas>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 防护建议 -->
    <div class="protection-tips">
      <h3>今日防护建议</h3>
      <div class="tips-grid">
        <div v-for="tip in protectionTips" :key="tip.id" class="tip-card">
          <div class="tip-icon">{{ tip.icon }}</div>
          <div class="tip-content">
            <h4>{{ tip.title }}</h4>
            <p>{{ tip.description }}</p>
          </div>
          <div class="tip-action">
            <button @click="learnMore(tip)" class="learn-btn">了解更多</button>
          </div>
        </div>
      </div>
    </div>

    <!-- 快速检测 -->
    <div class="quick-detection">
      <h3>快速检测</h3>
      <div class="detection-panel">
        <div class="detection-input">
          <textarea v-model="quickInput" placeholder="输入可疑信息进行快速检测..." rows="4"></textarea>
          <div class="input-actions">
            <button @click="quickDetect" :disabled="!quickInput.trim()" class="detect-btn">
              <i class="icon">🔍</i>
              快速检测
            </button>
            <button @click="clearInput" class="clear-btn">清空</button>
          </div>
        </div>
        
        <div v-if="quickResult" class="detection-result">
          <div class="result-header">
            <h4>检测结果</h4>
            <div class="result-score" :class="getScoreClass(quickResult.score)">
              {{ quickResult.score }}分
            </div>
          </div>
          <div class="result-details">
            <div class="risk-level" :class="quickResult.riskLevel">
              风险等级: {{ quickResult.riskLevel }}
            </div>
            <div class="risk-factors">
              <div class="factors-title">主要风险因素:</div>
              <div class="factors-list">
                <span v-for="factor in quickResult.factors" :key="factor" class="factor-tag">
                  {{ factor }}
                </span>
              </div>
            </div>
            <div class="suggestion">
              <strong>建议：</strong>{{ quickResult.suggestion }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

// 响应式数据
const activeFilter = ref('all')
const quickInput = ref('')
const quickResult = ref(null)

// 风险统计
const riskStats = ref({
  high: 127,
  medium: 256,
  safe: 1543,
  total: 1926
})

// 警报过滤器
const alertFilters = ref([
  { id: 'all', name: '全部' },
  { id: 'high', name: '高风险' },
  { id: 'medium', name: '中风险' },
  { id: 'low', name: '低风险' }
])

// 最新警报
const alerts = ref([
  {
    id: 1,
    title: '电信诈骗高发警报',
    description: '最近24小时内检测到多起冒充客服的电信诈骗案例',
    time: '2024-01-15 14:30',
    type: '电信诈骗',
    level: 'high'
  },
  {
    id: 2,
    title: '网络购物诈骗提醒',
    description: '发现多个虚假购物网站，请注意识别',
    time: '2024-01-15 13:45',
    type: '网络诈骗',
    level: 'medium'
  },
  {
    id: 3,
    title: '投资理财诈骗警示',
    description: '高收益投资理财产品存在风险，请谨慎投资',
    time: '2024-01-15 12:20',
    type: '投资诈骗',
    level: 'medium'
  },
  {
    id: 4,
    title: '系统安全提示',
    description: '平台检测功能正常运行，防护能力良好',
    time: '2024-01-15 11:15',
    type: '系统提示',
    level: 'low'
  }
])

// 诈骗类型统计
const fraudStats = ref([
  { type: '电信诈骗', count: 145, percentage: 35, color: '#f44336' },
  { type: '网络诈骗', count: 98, percentage: 24, color: '#ff9800' },
  { type: '投资诈骗', count: 76, percentage: 18, color: '#ffeb3b' },
  { type: '兼职诈骗', count: 52, percentage: 13, color: '#4caf50' },
  { type: '其他诈骗', count: 41, percentage: 10, color: '#2196f3' }
])

// 实时活动
const recentActivities = ref([
  {
    id: 1,
    time: '14:35',
    description: '检测到可疑电话号码',
    result: '高风险'
  },
  {
    id: 2,
    time: '14:32',
    description: '分析短信内容',
    result: '安全'
  },
  {
    id: 3,
    time: '14:28',
    description: '网站安全检测',
    result: '中风险'
  },
  {
    id: 4,
    time: '14:25',
    description: '用户举报处理',
    result: '已处理'
  }
])

// 防护建议
const protectionTips = ref([
  {
    id: 1,
    icon: '🛡️',
    title: '谨慎接听陌生电话',
    description: '不要轻信自称银行、公安等机构的陌生来电，遇到要求转账的情况立即挂断'
  },
  {
    id: 2,
    icon: '💳',
    title: '保护个人信息',
    description: '不要在不明网站输入银行卡号、密码等敏感信息，定期更换密码'
  },
  {
    id: 3,
    icon: '🔍',
    title: '核实投资项目',
    description: '投资前通过官方渠道核实平台资质，警惕高收益、低风险的投资诱惑'
  },
  {
    id: 4,
    icon: '👥',
    title: '多方求证',
    description: '遇到可疑情况时，及时咨询家人朋友或拨打官方客服电话核实'
  }
])

// 计算属性
const filteredAlerts = computed(() => {
  if (activeFilter.value === 'all') return alerts.value
  return alerts.value.filter(alert => alert.level === activeFilter.value)
})

// 方法
const navigateTo = (path) => {
  router.push(`/user/antifraud/${path}`)
}

const viewAlert = (alert) => {
  console.log('查看警报:', alert)
}

const handleAlert = (alert) => {
  console.log('处理警报:', alert)
}

const learnMore = (tip) => {
  console.log('了解更多:', tip)
}

const quickDetect = () => {
  if (!quickInput.value.trim()) return
  
  // 模拟检测逻辑
  const score = Math.floor(Math.random() * 100)
  const riskLevel = score >= 70 ? '高' : score >= 30 ? '中' : '低'
  const factors = ['可疑关键词', '异常联系方式', '时间异常']
  const suggestion = score >= 70 ? '请立即停止相关操作，并联系相关机构核实' : 
                   score >= 30 ? '建议谨慎处理，多方核实信息真实性' : '信息相对安全，但仍需保持警惕'
  
  quickResult.value = {
    score,
    riskLevel,
    factors: factors.slice(0, Math.floor(Math.random() * 3) + 1),
    suggestion
  }
}

const clearInput = () => {
  quickInput.value = ''
  quickResult.value = null
}

const getScoreClass = (score) => {
  if (score >= 70) return 'high-risk'
  if (score >= 30) return 'medium-risk'
  return 'low-risk'
}

onMounted(() => {
  // 初始化图表
  drawFraudChart()
  drawTrendChart()
})

const drawFraudChart = () => {
  const canvas = document.querySelector('#fraudChart')
  if (!canvas) return
  
  const ctx = canvas.getContext('2d')
  const centerX = canvas.width / 2
  const centerY = canvas.height / 2
  const radius = 120
  
  let startAngle = 0
  fraudStats.value.forEach(stat => {
    const sliceAngle = (stat.percentage / 100) * 2 * Math.PI
    
    ctx.beginPath()
    ctx.arc(centerX, centerY, radius, startAngle, startAngle + sliceAngle)
    ctx.lineTo(centerX, centerY)
    ctx.fillStyle = stat.color
    ctx.fill()
    
    startAngle += sliceAngle
  })
}

const drawTrendChart = () => {
  const canvas = document.querySelector('#trendChart')
  if (!canvas) return
  
  const ctx = canvas.getContext('2d')
  const width = canvas.width
  const height = canvas.height
  
  // 绘制趋势线
  ctx.beginPath()
  ctx.strokeStyle = '#1e3c72'
  ctx.lineWidth = 2
  
  const points = [
    { x: 30, y: height - 50 },
    { x: 80, y: height - 70 },
    { x: 130, y: height - 60 },
    { x: 180, y: height - 90 },
    { x: 230, y: height - 110 },
    { x: 280, y: height - 100 }
  ]
  
  points.forEach((point, index) => {
    if (index === 0) {
      ctx.moveTo(point.x, point.y)
    } else {
      ctx.lineTo(point.x, point.y)
    }
  })
  
  ctx.stroke()
  
  // 绘制数据点
  points.forEach(point => {
    ctx.beginPath()
    ctx.arc(point.x, point.y, 4, 0, 2 * Math.PI)
    ctx.fillStyle = '#ff9800'
    ctx.fill()
  })
}
</script>

<style scoped>
.antifraud-index {
  padding: 20px;
  max-width: 1600px;
  margin: 0 auto;
  background: #f5f7fa;
  min-height: 100vh;
}

/* 响应式设计 */
@media (max-width: 1600px) {
  .antifraud-index {
    width: 90%;
  }
}

@media (max-width: 1200px) {
  .antifraud-index {
    width: 95%;
  }
}

@media (max-width: 768px) {
  .antifraud-index {
    width: 100%;
    padding: 10px;
  }
}

.page-header {
  text-align: center;
  margin-bottom: 30px;
}

.page-header h1 {
  color: #1e3c72;
  margin-bottom: 10px;
}

.page-header p {
  color: #666;
  font-size: 16px;
}

.risk-overview {
  margin-bottom: 30px;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.overview-card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.overview-card:hover {
  transform: translateY(-5px);
}

.overview-card.risk-high {
  border-left: 4px solid #f44336;
}

.overview-card.risk-medium {
  border-left: 4px solid #ff9800;
}

.overview-card.risk-low {
  border-left: 4px solid #4caf50;
}

.overview-card.total-checks {
  border-left: 4px solid #2196f3;
}

.card-icon {
  font-size: 32px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9ff;
  border-radius: 10px;
}

.card-content {
  flex: 1;
}

.card-title {
  color: #666;
  font-size: 14px;
  margin-bottom: 5px;
}

.card-value {
  font-size: 28px;
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.card-trend {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #666;
}

.trend-icon {
  font-size: 14px;
}

.quick-nav {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.quick-nav h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 15px;
}

.nav-item {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-item:hover {
  background: #e8f0ff;
  transform: translateX(5px);
}

.nav-icon {
  font-size: 24px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.nav-content {
  flex: 1;
}

.nav-content h4 {
  color: #333;
  margin: 0 0 5px 0;
}

.nav-content p {
  color: #666;
  margin: 0;
  font-size: 14px;
}

.nav-arrow {
  font-size: 18px;
  color: #1e3c72;
  font-weight: bold;
}

.latest-alerts {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.alerts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.alerts-header h3 {
  color: #1e3c72;
  margin: 0;
}

.alert-filters {
  display: flex;
  gap: 5px;
}

.filter-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  background: white;
  color: #666;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn.active {
  background: #1e3c72;
  color: white;
  border-color: #1e3c72;
}

.alerts-list {
  display: grid;
  gap: 15px;
}

.alert-item {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  border-left: 4px solid #ddd;
}

.alert-item.high {
  border-left-color: #f44336;
}

.alert-item.medium {
  border-left-color: #ff9800;
}

.alert-item.low {
  border-left-color: #4caf50;
}

.alert-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: bold;
  color: #333;
  margin-bottom: 5px;
}

.alert-description {
  color: #666;
  font-size: 14px;
  margin-bottom: 8px;
}

.alert-meta {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: #999;
}

.alert-actions {
  display: flex;
  gap: 10px;
}

.view-btn,
.handle-btn {
  padding: 6px 12px;
  border: 1px solid #1e3c72;
  background: white;
  color: #1e3c72;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
}

.handle-btn {
  background: #1e3c72;
  color: white;
}

.view-btn:hover,
.handle-btn:hover {
  background: #2a5298;
  color: white;
}

.fraud-analysis {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.fraud-analysis h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.analysis-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.fraud-chart {
  display: flex;
  justify-content: center;
  align-items: center;
}

.fraud-stats {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 15px;
}

.stat-label {
  min-width: 80px;
  font-size: 14px;
  color: #333;
}

.stat-bar {
  flex: 1;
  height: 20px;
  background: #f0f0f0;
  border-radius: 10px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.stat-value {
  font-size: 14px;
  font-weight: bold;
  color: #666;
  min-width: 100px;
  text-align: right;
}

.real-time-monitor {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.real-time-monitor h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.monitor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.monitor-item {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 15px;
}

.monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.monitor-header h4 {
  color: #333;
  margin: 0;
}

.status-indicator {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 12px;
  background: #e8f5e8;
  color: #4caf50;
}

.trend-indicator {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 12px;
  background: #fff3e0;
  color: #ff9800;
}

.activity-list {
  display: grid;
  gap: 10px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: white;
  border-radius: 5px;
  font-size: 12px;
}

.activity-time {
  color: #666;
  min-width: 40px;
}

.activity-desc {
  flex: 1;
  color: #333;
}

.activity-result {
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: bold;
  font-size: 10px;
}

.activity-result.高风险 {
  background: #ffebee;
  color: #f44336;
}

.activity-result.中风险 {
  background: #fff3e0;
  color: #ff9800;
}

.activity-result.安全 {
  background: #e8f5e8;
  color: #4caf50;
}

.activity-result.已处理 {
  background: #e3f2fd;
  color: #2196f3;
}

.trend-chart {
  display: flex;
  justify-content: center;
  align-items: center;
}

.protection-tips {
  background: white;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.protection-tips h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.tip-card {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.tip-icon {
  font-size: 24px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tip-content {
  flex: 1;
}

.tip-content h4 {
  color: #333;
  margin: 0 0 10px 0;
}

.tip-content p {
  color: #666;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.tip-action {
  margin-top: 10px;
}

.learn-btn {
  background: #1e3c72;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s ease;
}

.learn-btn:hover {
  background: #2a5298;
}

.quick-detection {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.quick-detection h3 {
  color: #1e3c72;
  margin-bottom: 20px;
}

.detection-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.detection-input {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 15px;
}

.detection-input textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 5px;
  padding: 10px;
  font-size: 14px;
  resize: vertical;
}

.input-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.detect-btn {
  background: #1e3c72;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.3s ease;
}

.detect-btn:hover:not(:disabled) {
  background: #2a5298;
}

.detect-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.clear-btn {
  background: #f5f5f5;
  color: #666;
  border: 1px solid #ddd;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background: #e8e8e8;
}

.detection-result {
  background: #f8f9ff;
  border-radius: 8px;
  padding: 15px;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.result-header h4 {
  color: #333;
  margin: 0;
}

.result-score {
  font-size: 24px;
  font-weight: bold;
  padding: 5px 10px;
  border-radius: 5px;
}

.result-score.high-risk {
  background: #ffebee;
  color: #f44336;
}

.result-score.medium-risk {
  background: #fff3e0;
  color: #ff9800;
}

.result-score.low-risk {
  background: #e8f5e8;
  color: #4caf50;
}

.result-details {
  display: grid;
  gap: 15px;
}

.risk-level {
  font-weight: bold;
  padding: 8px 12px;
  border-radius: 5px;
}

.risk-level.高 {
  background: #ffebee;
  color: #f44336;
}

.risk-level.中 {
  background: #fff3e0;
  color: #ff9800;
}

.risk-level.低 {
  background: #e8f5e8;
  color: #4caf50;
}

.risk-factors {
  background: white;
  border-radius: 5px;
  padding: 10px;
}

.factors-title {
  font-weight: bold;
  color: #333;
  margin-bottom: 8px;
}

.factors-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.factor-tag {
  background: #1e3c72;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.suggestion {
  background: white;
  border-radius: 5px;
  padding: 10px;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .antifraud-index {
    padding: 10px;
  }
  
  .overview-cards {
    grid-template-columns: 1fr;
  }
  
  .nav-grid {
    grid-template-columns: 1fr;
  }
  
  .analysis-content {
    grid-template-columns: 1fr;
  }
  
  .monitor-grid {
    grid-template-columns: 1fr;
  }
  
  .tips-grid {
    grid-template-columns: 1fr;
  }
  
  .detection-panel {
    grid-template-columns: 1fr;
  }
}
</style> 